{% extends 'admin/reports_base.html' %}
{% load i18n adminmedia %}

{% block extrastyle %}
	{{ block.super }}
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/cupertino/jquery-ui.css" type="text/css" />
{% endblock %}

{% block breadcrumbs %}
	<div class="breadcrumbs">
		<a href="/admin/">{% trans "Home" %}</a> &gt; 
		<a href="{% url admin_reports %}">Reports</a> &gt; 
		<a href="">Subscriptions</a>
	</div>
{% endblock %}

{% block report %}
	<h1>Shop Subscriptions</h1>			
	{% if shops %}
		<div class="grid_20 margin_v">
			<div class="grid_3 alpha omega"><span><b>{% trans "Shop Name" %}</b></span></div>
			<div class="grid_3 alpha omega"><span><b>{% trans "Activity Start Date" %}</b></span></div>
			<div class="grid_4 alpha omega"><span><b>{% trans "Dns" %}</b></span></div>
			<div class="grid_3 alpha omega"><span><b>{% trans "User" %}</b></span></div>
			<div class="grid_4 alpha omega"><span><b>{% trans "Email" %}</b></span></div>
			<div class="grid_3 alpha omega"><span><b>{% trans "Options" %}</b></span></div>
		</div>
		<div class="clear"></div>
		<hr></hr>
		{% for shop in shops %}
		<div class="grid_20 margin_v">
			<div class="grid_3 alpha omega"><span>{{ shop.name }}</span></div>
			<div class="grid_3 alpha omega"><span>{{ shop.date_time|date:"Y-m-d" }}</span></div>
			<div class="grid_4 alpha omega"><span title="{{ shop.default_dns }}">
			{% if shop.default_dns|length > 25 %}{{ shop.default_dns|slice:"25" }}...{% else %} {{ shop.default_dns }}{% endif %}</span></div>
			<div class="grid_3 alpha omega"><span>{{ shop.owner.get_full_name }}({{ shop.owner.username }})</span></div>
			<div class="grid_4 alpha omega"><span title="{{ shop.owner.email }}">
			{% if shop.owner.email|length > 25 %}{{ shop.owner.email|slice:"25" }}...{% else %} {{ shop.owner.email }}{% endif %}</span></div>
			<div class="grid_3 alpha omega"><span><a href="#" onclick="javascript:mostrar('{% url admin_shop_subscription_details shop.id %}')">Subscription</a></span></div>
		</div>
		<div class="clear"></div>
		{% endfor %}
	{% else %}
		<h3>{% trans "No shops found." %}</h3>
	{% endif %}
	
	<div id="progress" class="dialogContent" style="text-align: center; display: none; width: 100px; height: 100px;">
		<img id="img1" src="{{ STATIC_URL }}img/ajax-loader.gif"/>
		<p>Loading...</p>
	</div>
	
	<script type="text/javascript">
	
    function mostrar(url){
		window.location = "" + url ;
		ShowProgressAnimation();
	}
	
	function ShowProgressAnimation() {
    	var pleaseWaitDialog = $("#progress").dialog({
				    resizable: false,
				    draggable: false,
				    height: 'auto',
				    modal: true,
				    closeText: '',
				    bgiframe: true,
				    closeOnEscape: false,
				    dialogClass : 'alert',				    
				    open: function(type, data) {
				    	$('#img1').attr('src', '{{ STATIC_URL }}img/ajax-loader.gif');
				    	$(".ui-dialog-titlebar-close").hide();
				    	$(".ui-dialog-titlebar").hide();
    					$(this).parent().appendTo($("form:first"));
    					$('body').css('overflow', 'auto'); //IE scrollbar fix for long checklist templates
    				}    				
    	});
    }
	</script>	
	
{% endblock %}